use "C:\Users\mjoshi2\Box\2020 Research\OSV and IMP\Journal of Human Rights\Stability data\2020-05-05 Stability Data.dta", replace 
log using "C:\Users\mjoshi2\Box\2020 Research\OSV and IMP\Journal of Human Rights\Stability data\Results.smcl", replace 

sort caseid year_count

//Subset the Data
keep caseid year_count country country_accorddate agg_imp_rate_woe1 agg_imp_rate_woe1 one_sided_violence one_sided_violence  govt_onesided_violence  govt_onesided_violence rebel_onesided_violence rebel_onesided_violence non_state_violence non_state_violence conflict_type batt_deaths_allwars gdp_growth_annual_perc polity_2_1lag dispute_implem powtran_implem  verify_implem donor_implem  unpkf_implem

//Summary Statistics Table 1
sum agg_imp_rate_woe1 L.agg_imp_rate_woe1 one_sided_violence L.one_sided_violence  govt_onesided_violence  L.govt_onesided_violence rebel_onesided_violence L.rebel_onesided_violence non_state_violence L.non_state_violence L.conflict_type L.batt_deaths_allwars L.gdp_growth_annual_perc polity_2_1lag L.dispute_implem L.powtran_implem  L.verify_implem L.donor_implem  L.unpkf_implem 

//Figure 1 Implementation Rate over time

graph bar (mean) agg_imp_rate_woe1, over(year_count) blabel(bar, format(%10.0f))

//Figure 2
//govt
graph bar (count) one_sided_violence if one_sided_violence >0, over(year_count) blabel(bar, format(%10.0f))
graph bar (count) non_state_violence if non_state_violence >0, over(year_count) blabel(bar, format(%10.0f))
graph bar (count) rebel_onesided_violence if rebel_onesided_violence >0, over(year_count) blabel(bar, format(%10.0f))
graph bar (count) govt_onesided_violence if govt_onesided_violence>0, over(year_count) allcategories blabel(bar, format(%10.0f))


//Table 2
xtivreg agg_imp_rate_woe1 (one_sided_violence =  polity_2_1lag L.gdp_growth_annual_perc   L.agg_imp_rate_woe1) L.batt_deaths_allwars L.dispute_implem L.powtran_implem  L.verify_implem L.donor_implem  L.unpkf_implem, fe
xtoverid
vif, uncentered
margins, at(one_sided_violence =(0(10)100))
marginsplot

xtivreg agg_imp_rate_woe1 (non_state_violence =L.govt_onesided_violence  polity_2_1lag L.gdp_growth_annual_perc  L.rebel_onesided_violence L.agg_imp_rate_woe1) L.batt_deaths_allwars L.dispute_implem L.powtran_implem  L.verify_implem L.donor_implem  L.unpkf_implem, fe
xtoverid
vif, uncentered
margins, at(non_state_violence =(10(10)100))
marginsplot

xtivreg agg_imp_rate_woe1 (rebel_onesided_violence=govt_onesided_violence L.non_state_violence  polity_2_1lag L.gdp_growth_annual_perc   L.agg_imp_rate_woe1) L.batt_deaths_allwars L.dispute_implem L.powtran_implem  L.verify_implem L.donor_implem  L.unpkf_implem, fe
xtoverid
vif, uncentered
margins, at(rebel_onesided_violence =(10(10)100))
marginsplot

xtivreg agg_imp_rate_woe1 (govt_onesided_violence=L.non_state_violence  polity_2_1lag L.gdp_growth_annual_perc  L.rebel_onesided_violence L.agg_imp_rate_woe1) L.batt_deaths_allwars L.dispute_implem L.powtran_implem  L.verify_implem L.donor_implem  L.unpkf_implem, fe
xtoverid
vif, uncentered
margins, at(govt_onesided_violence =(10(10)100))
marginsplot


log close
